class Wue {
  constructor (options) {
    //保存配置项
    this.$options = options || {}
    //保存dom
    this.$el =
      typeof options.el === 'string'
        ? document.querySelector(options.el)
        : options.el
    //保存data
    this.$data = options.data
    //注册data的属性到wm实例上
    this._proxyData()
    //监听data属性值的变化
    new Observer(options.data)
    //解析指令和插值表达式
    new Complier(this)
  }

  //将data属性的值注册到options上
  _proxyData () {
    Object.keys(this.$data).forEach(key => {
      Object.defineProperty(this, key, {
        enumerable: true,
        configurable: true,
        get () {
          return this.$data[key]
        },
        set (newVal) {
          if (this.$data[key] !== newVal) {
            this.$data[key] = newVal
          }
        }
      })
    })
  }
}
